package com.xing.controller;

import com.xing.domain.User;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @RequestMapping(value = "/hello")
    public String hello(){
        return "Hello Swagger!";
    }

    // 只要接口 的返回值中存在实体类，就会被扫描到swagger中
    @PostMapping(value = "/user")
    public User helloA(){
        return new User();
    }

    // Operation接口 不是放在类上 是方法上
    @ApiOperation("HelloT接口")
    @GetMapping(value = "/helloT")
    public String helloC(@ApiParam("用户名") String username){
        return "hello"+username;
    }

    // Operation接口 不是放在类上 是方法上
    @ApiOperation("Post测试类")
    @PostMapping(value = "/helloTest")
    public String helloD(@ApiParam("用户名") User user){
        int i = 5/0;
        return "hello"+user;
    }
}
